package com.yuyou.tas.feedback.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import com.yuyou.tas.feedback.service.IFeedbackTeacherPraiseService;
import com.yuyou.tas.service.api.feedback.entity.FeedbackTeacherPraise;
import com.yuyou.tas.service.api.feedback.service.FeedbackPraiseAPI;
import com.yuyou.tas.util.tool.DateUtil;
import com.yuyou.tas.util.tool.Sequence;

@RestController
public class FeedbackPraiseAPIImpl implements FeedbackPraiseAPI{

    @Autowired
    private IFeedbackTeacherPraiseService feedbackTeacherPraiseService;

    @Override
    public void saveFeedbackPraise(Long feedbackClassId, Long receUserId, Long sendUserId, Long organId) {
        FeedbackTeacherPraise feedbackTeacherPraise = new FeedbackTeacherPraise();
        feedbackTeacherPraise.setId(Sequence.getSequence().nextId());
        feedbackTeacherPraise.setAuthOrganizationId(organId);
        feedbackTeacherPraise.setFeedbackClassId(feedbackClassId);
        feedbackTeacherPraise.setReceUserId(receUserId);
        feedbackTeacherPraise.setSendUserId(sendUserId);
        feedbackTeacherPraise.setIsPraise(0);
        feedbackTeacherPraise.setCreateTime(DateUtil.now());
        feedbackTeacherPraiseService.insert(feedbackTeacherPraise);
    }

    @Override
    public Long countPraiseByFeedbackClassId(Long feedbackClassId) {
    	return feedbackTeacherPraiseService.countPraiseByFeedbackClassId(feedbackClassId);
    }

    @Override
    public Long countPraiseByFeedbackClassIdUserId(Long feedbackClassId, Long sendUserId) {
    	return feedbackTeacherPraiseService.countPraiseByFeedbackClassIdUserId(feedbackClassId, sendUserId);
    }
}
